home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / pyshared / lib / strippers.py < prev   
Encoding:
Python Source  |  2012-05-27  |  1.7 KB  |  68 lines

  1. '''
  2.     Manage which fileformat can be processed
  3. '''
  4.  
  5. import images
  6. import audio
  7. import office
  8. import archive
  9. import misc
  10. import subprocess
  11.  
  12. STRIPPERS = {
  13.     'application/x-tar': archive.TarStripper,
  14.     'application/x-gzip': archive.GzipStripper,
  15.     'application/x-bzip2': archive.Bzip2Stripper,
  16.     'application/zip': archive.ZipStripper,
  17.     'audio/mpeg': audio.MpegAudioStripper,
  18.     'application/x-bittorrent': misc.TorrentStripper,
  19.     'application/opendocument': office.OpenDocumentStripper,
  20.     'application/officeopenxml': office.OpenXmlStripper,
  21. }
  22.  
  23.  
  24. # PDF support
  25. pdfSupport = True
  26. try:
  27.     import poppler
  28. except ImportError:
  29.     print('Unable to import python-poppler: not PDF support')
  30.     pdfSupport = False
  31.  
  32. try:
  33.     import cairo
  34. except ImportError:
  35.     print('Unable to import python-cairo: no PDF support')
  36.     pdfSupport = False
  37.  
  38. try:
  39.     import pdfrw
  40. except ImportError:
  41.     print('Unable to import python-pdfrw: no PDf support')
  42.     pdfSupport = False
  43.  
  44. if pdfSupport:
  45.     STRIPPERS['application/x-pdf'] = office.PdfStripper
  46.     STRIPPERS['application/pdf'] = office.PdfStripper
  47.  
  48.  
  49. # audio format support with mutagen-python
  50. try:
  51.     import mutagen
  52.     STRIPPERS['audio/x-flac'] = audio.FlacStripper
  53.     STRIPPERS['audio/vorbis'] = audio.OggStripper
  54. except ImportError:
  55.     print('Unable to import python-mutagen: limited audio format support')
  56.  
  57. # exiftool
  58. try:
  59.     subprocess.Popen('exiftool', stdout=open('/dev/null'))
  60.     import exiftool
  61.     STRIPPERS['image/jpeg'] = exiftool.JpegStripper
  62.     STRIPPERS['image/png'] = exiftool.PngStripper
  63. except:  # if exiftool is not installed, use hachoir
  64.     print('Unable to find exiftool: limited images support')
  65.     STRIPPERS['image/jpeg'] = images.JpegStripper
  66.     STRIPPERS['image/png'] = images.PngStripper
  67.  
  68.